unit CadastroParametrosCompra;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, DBClient, Provider, DB, DBTables, Menus, StdCtrls,
  ComCtrls, DBCtrls, Buttons, Grids, DBGrids, ExtCtrls, Mask, ToolEdit,
  CurrEdit, RXDBCtrl;

type
  TFCadastroParametrosCompra = class(TFormCadastro)
    DBCheckBox1: TDBCheckBox;
    cdsCadastroPAR_CODIGO: TIntegerField;
    cdsCadastroPAR_ASS1: TStringField;
    cdsCadastroPAR_ASS2: TStringField;
    cdsCadastroPAR_ASS3: TStringField;
    cdsCadastroUSUARIO: TStringField;
    cdsCadastroDATAMODIFICACAO: TDateTimeField;
    cdsCadastroPAR_PLANOJUROSMULTAE: TIntegerField;
    cdsCadastroPAR_PLANOJUROSMULTAS: TIntegerField;
    cdsCadastroPAR_DATAREPROCESSAMENTOESTOQUE: TDateTimeField;
    cdsCadastroPAR_TIPOMOVIMENTOPEDIDOVENDA: TIntegerField;
    cdsCadastroPAR_TIPOMOVIMENTOROMANEIO: TIntegerField;
    cdsCadastroPAR_TIPOMOVIMENTOCANCELANFVENDA: TIntegerField;
    cdsCadastroPAR_PERCIRRF: TFloatField;
    cdsCadastroPAR_PERCISS: TFloatField;
    cdsCadastroPAR_PERCPIS: TFloatField;
    cdsCadastroPAR_PERCCOFINS: TFloatField;
    cdsCadastroPAR_PERCCSLL: TFloatField;
    cdsCadastroPAR_PERCINSS: TFloatField;
    cdsCadastroPAR_TIPOVENDASERVICO: TIntegerField;
    cdsCadastroPAR_LOCALSERVICO: TIntegerField;
    cdsCadastroPAR_ESPECIEBOLETO: TStringField;
    cdsCadastroPAR_CARTEIRABOLETO: TStringField;
    cdsCadastroPAR_INTRUCAO: TStringField;
    cdsCadastroPAR_INICIACENTROCUSTO: TSmallintField;
    cdsCadastroPAR_SIMBOLOMOEDA: TStringField;
    cdsCadastroPAR_MOEDASINGULAR: TStringField;
    cdsCadastroPAR_MOEDAPLURAL: TStringField;
    cdsCadastroIN_CONF_IMPRE_NOTA_ID: TIntegerField;
    cdsCadastroIN_CONF_IMPRE_BOLETO_ID: TIntegerField;
    cdsCadastroNUMERONOTAFISCALENTRADA: TIntegerField;
    cdsCadastroSERIENOTAFISCALENTRADA: TStringField;
    cdsCadastroNUMERONOTAFISCALSAIDA: TIntegerField;
    cdsCadastroSERIENOTAFISCALSAIDA: TStringField;
    cdsCadastroNUMEROSELO: TIntegerField;
    cdsCadastroSERIESELO: TStringField;
    cdsCadastroPAR_CIDADE_CHEQUE: TStringField;
    cdsCadastroTEXTO1: TStringField;
    cdsCadastroTEXTO2: TStringField;
    cdsCadastroTEXTO3: TStringField;
    cdsCadastroTEXTO4: TStringField;
    cdsCadastroTEXTO5: TStringField;
    cdsCadastroTEXTO6: TStringField;
    cdsCadastroTEXTO7: TStringField;
    cdsCadastroTEXTO8: TStringField;
    cdsCadastroTEXTO9: TStringField;
    cdsCadastroTEXTO10: TStringField;
    cdsCadastroTEXTO11: TStringField;
    cdsCadastroTEXTO12: TStringField;
    cdsCadastroCOD_EMPRESA: TIntegerField;
    cdsCadastroPAR_GRUPO_ENTRADA: TStringField;
    cdsCadastroPAR_GRUPO_SAIDA: TStringField;
    cdsCadastroPAR_DESCRICAO: TStringField;
    cdsCadastroPAR_CENTROCUSTO: TIntegerField;
    cdsCadastroPAR_CLASSIFICACAO: TIntegerField;
    cdsCadastroPAR_PORTADOR: TIntegerField;
    cdsCadastroPAR_TIPO_DOCTO: TIntegerField;
    cdsCadastroPAR_CONTACONTABIL: TIntegerField;
    cdsCadastroNUMERONOTAFISCALSERVICO: TIntegerField;
    cdsCadastroSERIENOTAFISCALSERVICO: TStringField;
    cdsCadastroIN_CONF_IMPRE_NOTA_SAIDA_ID: TIntegerField;
    cdsCadastroIN_CONF_IMPRE_NOTA_SERVICO_ID: TIntegerField;
    cdsCadastroIN_CONF_IMPRE_NOTA_BOLETO_ID: TIntegerField;
    cdsCadastroIN_CONF_IMPRE_NOTA_DUPLICATA_ID: TIntegerField;
    cdsCadastroPAR_FONTERECURSO: TIntegerField;
    cdsCadastroPAR_CENTRO_CUSTO_CP: TIntegerField;
    cdsCadastroPAR_CLASS_FINANC_CP: TIntegerField;
    cdsCadastroPAR_PORTADOR_CP: TIntegerField;
    cdsCadastroPAR_TIPO_DOCTO_CP: TIntegerField;
    cdsCadastroPAR_EST_PERIODO_LANC_INI: TDateTimeField;
    cdsCadastroPAR_EST_PERIODO_LANC_FIM: TDateTimeField;
    cdsCadastroPAR_EST_ULTIMA_ATUALIZACAO: TDateTimeField;
    cdsCadastroPAR_EST_LOCALESTOQUE: TIntegerField;
    cdsCadastroPAR_VEND_EDITACOMISSAO_PROD: TStringField;
    cdsCadastroPAR_VEND_EDITACOMISSAO_PED: TStringField;
    cdsCadastroPAR_VEND_EDITACOMISSAO_NF: TStringField;
    cdsCadastroPAR_DATALIMETE: TDateTimeField;
    cdsCadastroPAR_VENDA_QTD_DIAS_LIMITE1: TIntegerField;
    cdsCadastroPAR_VENDA_OBS_LIMITE1: TStringField;
    cdsCadastroPAR_VENDA_QTD_DIAS_LIMITE2: TIntegerField;
    cdsCadastroPAR_VENDA_OBS_LIMITE2: TStringField;
    cdsCadastroPAR_VENDA_QTD_DIAS_LIMITE3: TIntegerField;
    cdsCadastroPAR_VENDA_OBS_LIMITE3: TStringField;
    cdsCadastroPAR_VENDA_OBS_LIMITE4: TStringField;
    cdsCadastroPAR_DTPERIODOESTOQUE1: TDateTimeField;
    cdsCadastroPAR_DTPERIODOESTOQUE2: TDateTimeField;
    cdsCadastroPAR_GERAR_TXT_NF: TIntegerField;
    cdsCadastroPAR_DIRETORIO_TXT_NF: TStringField;
    cdsCadastroPAR_ID_EMPRESA_ROTINA: TStringField;
    cdsCadastroPAR_VENDA_NOTIFICAR_PEDIDO: TStringField;
    cdsCadastroPAR_GERA_MAPEAMENTO: TIntegerField;
    cdsCadastroPAR_LETRA_UNIDADE_REDE: TStringField;
    cdsCadastroPAR_CALCULO_IPI: TIntegerField;
    cdsCadastroPAR_NUMERACAO_UNICA_NF: TIntegerField;
    cdsCadastroUSUARIO_CADASTRO: TStringField;
    cdsCadastroUSUARIO_AUTERACAO: TStringField;
    cdsCadastroUSUARIO_EXCLUSAO: TStringField;
    cdsCadastroDATA_CADASTRO: TDateTimeField;
    cdsCadastroDATA_EXCLUSAO: TDateTimeField;
    cdsCadastroDATA_AUTERACAO: TDateTimeField;
    cdsCadastroEXCLUIDO: TStringField;
    cdsCadastroPAR_TIPOMOVTOCOMPRA: TIntegerField;
    cdsCadastroPAR_TIPOMOVTODEVCOMPRA: TIntegerField;
    cdsCadastroPAR_TIPOMOVTOREQUISICAO: TIntegerField;
    cdsCadastroPAR_TIPOMOVTODEVREQUISICAO: TIntegerField;
    cdsCadastroPAR_TIPOMOVTOTRANSENTRADA: TIntegerField;
    cdsCadastroPAR_TIPOMOVTOTRANSSAIDA: TIntegerField;
    cdsCadastroPAR_EST_DTULTIMOFECHAMENTO: TDateTimeField;
    cdsCadastroPAR_EST_MESES_CONMEDIO: TIntegerField;
    cdsCadastroPAR_EST_VR_DPA: TFloatField;
    cdsCadastroPAR_EST_PERC_VAR_MIM: TFloatField;
    cdsCadastroUSUARIO_RECUPERACAO: TStringField;
    cdsCadastroDATA_RECUPERACAO: TDateTimeField;
    cdsCadastroPAR_EST_DIAS_VALID_REQUISICAO: TIntegerField;
    cdsCadastroPAR_VEND_SERIE_RPS: TStringField;
    cdsCadastroPAR_VEND_VERSAO_RPS: TStringField;
    cdsCadastroPAR_VEND_NRPS: TIntegerField;
    cdsCadastroPAR_VEND_USA_NFSE: TStringField;
    cdsCadastroPAR_VEND_USA_NFME: TStringField;
    cdsCadastroPAR_VEND_USA_SELO: TStringField;
    cdsCadastroPAR_CAMINHO_ARQUIVO_RPS: TStringField;
    cdsCadastroPAR_EMP_DESC: TStringField;
    cdsCadastroPAR_COMPRA_DIGITACAO_PEDIDO: TStringField;
    cdsCadastroPAR_COMPRA_GERAPEDSEMCOTACAO: TStringField;
    cdsCadastroPAR_EST_ESTOQUENEGATIVO: TStringField;
    cdsCadastroPAR_EST_OBRIGA_PEDIDO: TStringField;
    GroupBox1: TGroupBox;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    RxDBCalcEdit1: TRxDBCalcEdit;
    RxDBCalcEdit2: TRxDBCalcEdit;
    procedure BtnSalvarClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCadastroParametrosCompra: TFCadastroParametrosCompra;

implementation

uses UGeral, UDmFinanceiro, UDmGestao;

{$R *.dfm}

procedure TFCadastroParametrosCompra.BtnSalvarClick(Sender: TObject);
begin
  inherited;
  {TODO: Criar campo no banco para este parametro}
end;

procedure TFCadastroParametrosCompra.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FCadastroParametrosCompra := nil;
  action := cafree;
end;

procedure TFCadastroParametrosCompra.FormCreate(Sender: TObject);
const Sql_Parametro = ' SELECT * FROM PARAMETRO WHERE CODIGOEMPRESA = %s ';
begin
  inherited;

  try
   QCadastro.Close;
   QCadastro.SQL.Clear;
   QCadastro.SQL.Add(format(Sql_Parametro,[IntToStr(Codigoempresa)]));
   QCadastro.Open;
   cdsCadastro.Close;
   cdsCadastro.Open;
   pcCadastro.ActivePage := TsCadastro;
  Except
   exit;
  end;

end;

procedure TFCadastroParametrosCompra.FormShow(Sender: TObject);
begin
  inherited;
  BtnExcluir.Visible := False;
end;

end.
